var Express = require('express')
var app = Express()
var cors = require('cors')
var BodyParser = require('body-parser');
var mongoose = require('mongoose')
require('dotenv').config()

app.use(cors())
app.use(BodyParser.urlencoded({ extended: false }));
app.use(BodyParser.json());

app.use('/api', require('./routes/api'))
app.use('/fd', require('./routes/fd'))

app.use(Express.static(__dirname + '/../public'));

app.set('views',__dirname + '/views');
app.set('view engine', 'ejs');

mongoose.connect(
  process.env.DATABASE_URL,
  { useNewUrlParser: true, useCreateIndex: true },
).then(() => console.log('mongo started at 27017'));

app.listen(8020, () => console.log('web started at 8020'))